#include <algorithm>
#include <cstdio>

const int N = 500005;
int n, m, ans;
char opt[2];

struct Node {
  int maxl, maxr, max, tag;
} tr[N << 2];

inline void pushup(int x, int l, int r) {
  static int ls, rs, mid;
  ls = x << 1, rs = x << 1 | 1, mid = (l + r) >> 1;
  tr[x].max =
      std::max(tr[ls].max, std::max(tr[rs].max, tr[ls].maxr + tr[rs].maxl));
  tr[x].maxl = tr[ls].maxl + ((tr[ls].maxl == (mid - l + 1)) ? tr[rs].maxl : 0);
  tr[x].maxr = tr[rs].maxr + ((tr[rs].maxr == (r - mid)) ? tr[ls].maxr : 0);
}

inline void pushdown(int x, int l, int r) {
  static int ls, rs, mid;
  if (tr[x].tag != -1) {
    mid = (l + r) >> 1, ls = x << 1, rs = x << 1 | 1;
    tr[ls].max = tr[ls].maxl = tr[ls].maxr = (tr[x].tag ? 0 : (mid - l + 1));
    tr[rs].max = tr[rs].maxl = tr[rs].maxr = (tr[x].tag ? 0 : (r - mid));
    tr[ls].tag = tr[rs].tag = tr[x].tag;
    tr[x].tag = -1;
  }
}

void build(int x, int l, int r) {
  tr[x].max = tr[x].maxl = tr[x].maxr = r - l + 1, tr[x].tag = -1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
}

void modify(int x, int l, int r, int L, int R, bool v) {
  if (L <= l && r <= R) {
    tr[x].tag = v;
    tr[x].max = tr[x].maxl = tr[x].maxr = (v ? 0 : (r - l + 1));
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(x, l, r);
  if (L <= mid) modify(x << 1, l, mid, L, R, v);
  if (mid < R) modify(x << 1 | 1, mid + 1, r, L, R, v);
  pushup(x, l, r);
}

int query(int x, int l, int r, int len) {
  static int ls, rs, mid;
  mid = (l + r) >> 1;
  pushdown(x, l, r);
  ls = x << 1, rs = x << 1 | 1;
  if (len <= tr[ls].max)
    return query(ls, l, mid, len);
  else if (tr[ls].maxr + tr[rs].maxl >= len)
    return mid - tr[ls].maxr + 1;
  else
    return query(rs, mid + 1, r, len);
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("CppTest.in", "r", stdin);
  freopen("CppTest.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  build(1, 1, n);
  for (int i = 1, a, b; i <= m; ++i) {
    scanf("%s", opt);
    if (opt[0] == 'A') {
      scanf("%d", &a);
      if (tr[1].max < a)
        ++ans;
      else
        b = query(1, 1, n, a), modify(1, 1, n, b, b + a - 1, true);
    } else {
      scanf("%d%d", &a, &b);
      modify(1, 1, n, a, b, false);
    }
  }
  printf("%d", ans);
  return 0;
}